/*
* @Author: qingsong-Liu
* @Date:   2019-08-25 09:29:29
* @Last Modified by:   qingsong-Liu
* @Last Modified time: 2019-08-29 09:59:22
*/
'use strict';

var _mm = require('util/mm.js');

var _address={
    // 获取地址列表
    getAddressList:function(resolve,reject){
        _mm.request({
            url     : _mm.getServerUrl('/shipping/list.do'),
            data    : {
                pageSize : 50
            },
            success : resolve,
            error   : reject
        });
    },
    // 新建收件人
    save:function(addressInfo,resolve,reject){
        _mm.request({
            url     : _mm.getServerUrl('/shipping/add.do'),
            data    : addressInfo,
            //todo 设为POST请求，方便接口测试,发布时要删除
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    // 更新收件人
    update:function(addressInfo,resolve,reject){
        _mm.request({
            url     : _mm.getServerUrl('/shipping/update.do'),
            data    : addressInfo,
            //todo 设为POST请求，方便接口测试,发布时要删除
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    // 删除收件人
    deleteAddress:function(shippingId,resolve,reject){
        _mm.request({
            url     : _mm.getServerUrl('/shipping/del.do'),
            data    : {
                shippingId : shippingId
            },
            //todo 设为POST请求，方便接口测试,发布时要删除
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    // 获取单条收件人信息
    getAddress:function(shippingId,resolve,reject){
        _mm.request({
            url     : _mm.getServerUrl('/shipping/select.do'),
            data    : {
                shippingId : shippingId
            },
            //todo 设为POST请求，方便接口测试,发布时要删除
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    }
}
module.exports = _address;